package net.bithappens.hnqe.impl;

import net.bithappens.hnqe.cache.ICache;
import net.bithappens.hnqe.cache.ICacheReadWrite;
import net.bithappens.hnqe.cache.ICacheTraverse;
import net.bithappens.hnqe.impl.cache.CacheManager;
import net.bithappens.hnqe.impl.mapper.MapperPool;
import net.bithappens.hnqe.impl.querymanager.QueryManager;
import net.bithappens.hnqe.mapper.IMapperPool;
import net.bithappens.hnqe.query.IQuery;

public class HNQE {

	private ICache cache;
	
	private IQuery queryManager;
	
	private IMapperPool mapperPool;
	
	
	
	public HNQE() throws Exception {
		
		cache = new CacheManager();
		
		mapperPool = new MapperPool(cache);
		
		mapperPool.loadMapper();
		
		queryManager = new QueryManager(cache, mapperPool);
		
	}
	
	
	public IQuery getQueryInterface(){
		return queryManager;
	}
	
	public ICacheReadWrite getCachAccessInterface(){
		return cache;
	}
	
	public ICacheTraverse getCachTraverseInterface(){
		return cache;
	}
	
	public void startFrameWork(){
		mapperPool.startMapper();
	}
	
	public void stopFrameWork(){
		mapperPool.stopMapper();
		((CacheManager) cache).stop();
	}

}
